package com.jk.vehicle.mini.controller;

import com.jk.vehicle.core.controller.BaseController;
import com.jk.vehicle.core.entity.ResponseEntity;
import com.jk.vehicle.mini.entity.Network;
import com.jk.vehicle.mini.service.CorpService;
import com.jk.vehicle.mini.service.NetworkService;
import com.jk.vehicle.mini.util.SequenceUtils;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.jk.vehicle.mini.vo.NetworkSelectListVo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;
import springfox.documentation.annotations.ApiIgnore;

import java.util.Date;
import javax.annotation.Resource;
import java.util.List;
import java.util.Map;

/**
 * This is Description for NetworkController
 *
 * @author Administrator
 * @date 2021/06/25
 */
@Api(value = "网点管理相关接口", tags = "网点管理相关接口")
@RestController
@RequestMapping("/network")
public class NetworkController extends BaseController {

	/**
	 * NetworkService服务
	 */
    @Resource
    private NetworkService networkService;

    @Resource
    private CorpService corpService;

    /**
     * 根据条件查询网点列表√
     * @param networkType 厂家id
     * @return
     */
    @ApiOperation(response = NetworkSelectListVo.class, value = "根据条件查询网点列表", notes = "根据条件查询网点列表 jiajiang 2021-06-25")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "lng", value = "经度"),
            @ApiImplicitParam(name = "lat", value = "纬度"),
            @ApiImplicitParam(name = "distance", value = "距离(单位：米)"),
            @ApiImplicitParam(name = "networkType", value = "网点类型（0：销售，1：维修）"),
            @ApiImplicitParam(name = "corpId", value = "厂家id")
    })
    @GetMapping(value = "/list")
    public ResponseEntity<List<NetworkSelectListVo>> list(@RequestParam(name = "lng") String lng, @RequestParam("lat") String lat,
                                                      @RequestParam("distance") Double distance, @RequestParam(value = "networkType") Integer networkType,
                                                      @RequestParam("corpId") Long corpId) {
        if (corpId == null || corpId.longValue() == 0) {
            return failResult("厂家id不能为空！");
        }
        if (corpId == -1) {
            return failResult("厂家id不能等于-1！");
        }
        String dsName = corpService.selectDsNameById(corpId);
        return successResult(networkService.list(lng, lat, distance, networkType, corpId, dsName));
    }

}
